package com.b2b.util;

import com.b2b.model.entity.InquiryMaterial;
import com.b2b.service.InquiryMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class InquiryMaterialUtil {
    private final InquiryMaterialService inquiryMaterialService;

    @Autowired
    public InquiryMaterialUtil(InquiryMaterialService inquiryMaterialService){
        this.inquiryMaterialService = inquiryMaterialService;
    }
    public int insertInquiryMaterial(InquiryMaterial inquiryMaterial){
        int count = inquiryMaterialService.insert(inquiryMaterial);
        return count;
    }

    public Integer getRequirementId(Integer inquiryId){
        InquiryMaterial inquiryMaterial = new InquiryMaterial();
        inquiryMaterial.setInquiryId(inquiryId);
        inquiryMaterial = inquiryMaterialService.selectOne(inquiryMaterial);
        Integer requirementId = inquiryMaterial.getRequirementId();
        return requirementId;
    }

    public List<InquiryMaterial> getInquiryMaterialByInquiryId(Integer inquiryId){
        InquiryMaterial inquiryMaterial = new InquiryMaterial();
        inquiryMaterial.setInquiryId(inquiryId);
        List<InquiryMaterial> inquiryMaterialList = inquiryMaterialService.select(inquiryMaterial);
        return inquiryMaterialList;
    }

    public Integer deleteInquiryMaterial(InquiryMaterial inquiryMaterial){
        Integer count = inquiryMaterialService.delete(inquiryMaterial);
        return count;
    }
}
